<script setup>
import { RouterLink, RouterView } from 'vue-router'
</script>

<template>
  <div class="app desktop-layout">
    <!-- 侧边栏导航 -->
    <aside class="sidebar">
      <div class="sidebar-header">
        <RouterLink to="/" class="sidebar-logo">
          <img alt="Logo" src="@/assets/logo.svg" width="50" height="50" />
          <span>ModernWeb</span>
        </RouterLink>
      </div>
      
      <nav class="sidebar-nav">
        <RouterLink to="/" class="sidebar-link">
          <span class="icon">🏠</span>
          <span>首页</span>
        </RouterLink>
        <RouterLink to="/about" class="sidebar-link">
          <span class="icon">👥</span>
          <span>关于我们</span>
        </RouterLink>
        <RouterLink to="/services" class="sidebar-link">
          <span class="icon">🛠️</span>
          <span>服务</span>
        </RouterLink>
        <RouterLink to="/contact" class="sidebar-link">
          <span class="icon">📧</span>
          <span>联系我们</span>
        </RouterLink>
      </nav>
      
      <div class="sidebar-footer">
        <p class="sidebar-copyright">© 2024 ModernWeb</p>
      </div>
    </aside>

    <!-- 主内容区域 -->
    <main class="main-content">
      <RouterView />
    </main>
  </div>
</template>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #f8fafc;
  color: #1a202c;
}

/* 电脑端侧边栏布局 */
.desktop-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  background: linear-gradient(180deg, #1a202c 0%, #2d3748 100%);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
  padding: 2rem;
  border-bottom: 1px solid #4a5568;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-weight: 700;
  font-size: 1.5rem;
  color: white;
  text-decoration: none;
}

.sidebar-nav {
  flex: 1;
  padding: 2rem 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 2rem;
  color: #a0aec0;
  text-decoration: none;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-left-color: #667eea;
}

.sidebar-link.router-link-active {
  background: rgba(102, 126, 234, 0.2);
  color: white;
  border-left-color: #667eea;
}

.sidebar-link .icon {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 2rem;
  border-top: 1px solid #4a5568;
  text-align: center;
}

.sidebar-copyright {
  color: #a0aec0;
  font-size: 0.875rem;
}

.main-content {
  flex: 1;
  margin-left: 280px;
  min-height: 100vh;
}

/* 隐藏移动端导航 */
.navbar {
  display: none;
}

/* 响应式设计 - 移动端 */
@media (max-width: 1024px) {
  .desktop-layout {
    flex-direction: column;
  }
  
  .sidebar {
    display: none;
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .navbar {
    display: block;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
  }
  
  .nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
  }
  
  .nav-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: #2563eb;
    text-decoration: none;
  }
  
  .nav-menu {
    display: flex;
    gap: 2rem;
  }
  
  .nav-link {
    text-decoration: none;
    color: #4a5568;
    font-weight: 500;
    transition: color 0.2s;
  }
  
  .nav-link:hover,
  .nav-link.router-link-active {
    color: #2563eb;
  }
}

@media (max-width: 768px) {
  .nav-container {
    padding: 0 1rem;
  }
  
  .nav-menu {
    gap: 1rem;
  }
  
  .nav-link {
    font-size: 0.875rem;
  }
}
</style>
